package com.risk.modules.rm.dao;

import com.risk.modules.rm.entity.Dictionary;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DictionaryDao {
    @Insert(value="INSERT INTO `dictionary`(`id`, `value`, `label`, `type`, `description`, `sort`, `parent_id`) " +
            "VALUES (#{dictionary.id}, #{dictionary.value}, #{dictionary.label}, #{dictionary.type}, #{dictionary.description}, #{dictionary.sort}, #{dictionary.parentId})")
    int add(@Param("dictionary") Dictionary dictionary);

    @Select(value = "SELECT * FROM `dictionary` WHERE 1 = 1 ${whereClause} ORDER BY sort")
    List<Dictionary> queryByCondition(@Param("whereClause") String whereClause);

    @Select(value = "SELECT count(1) FROM `dictionary` WHERE 1=1 ${whereClause}")
    int countByCondition(@Param("whereClause") String whereClause);

    @Delete(value = "UPDATE `dictionary` SET `del_flag` = '1' WHERE `id` = #{0}")
    int del(String id);
}
